<template>
	<div class="body">
		<h2>敏感词编辑器——注意回车标识一个敏感词</h2>
		<br />
		<el-input class="editor" type="textarea" :rows="40" placeholder="请输入内容" v-model="content">
		</el-input>
		<el-button type="success" round v-on:click="onEditor()">保存</el-button>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				content: "",
			};
		},
		created() {
			this.load()
		},
		methods: {
			onEditor() {
				console.log(this.content);
				this.save()
			},

			load() {
				this.request.get("/api/tweet/getSensitiveTxt")
					.then(res => {
						console.log(res)
						this.content = res.result
					})
			},
			save() {
				this.request({
					url: "/api/tweet/setSensitiveTxt",
					method: 'post',
					data: this.content
				}).then(res => {
					if (res.code == 200) {
						this.$message.success("保存成功")
						this.dialogFormVisible = false
						this.load()
					} else {
						this.$message.error("保存失败")
					}
				})
			},
		},
	};
</script>

<style scoped>
	.body {
		height: 100vh;
	}

	.editor {
		height: 80vh;
	}

	.button {
		margin-left: 50%;
		margin-top: 50px;
	}
</style>
